package com.erp.bean;

public class PhotoProcess {
    private String url = "";
    private String urlh = "";
    private String process = "";
    private String process2 = "";
    private String OSSAccessKeyId = "";
    private String Expires = "";
    private String Signature = "";
    private String Signature2 = "";
    private Boolean is2 = false;
    public void seturl(String url){
        this.url = url;
        if(url.indexOf("x-oss-process-2") != -1){

            String[] s1 = url.split("\\?");
            if(s1.length  < 2){
                return;
            }
            this.urlh = s1[0];
            String[] s2 = s1[1].split("&");
            if(s2.length < 2){
                return;
            }
            for (int i = 0 ; i< s2.length ; i++){
                String[] s3 = s2[i].split("=");
                if(s3.length < 2){
                    return;
                }
                switch (s3[0]){
                    case "x-oss-process" : process = s3[1];
                    case "OSSAccessKeyId" : OSSAccessKeyId = s3[1];
                    case "Expires" : Expires = s3[1];
                    case "Signature" : Signature = s3[1];
                    case "x-oss-process-2" : process2 = s3[1];
                    case "Signature-2" : Signature2 = s3[1];
                }
            }
            is2 = true;
        }
    }

    public String getUrl(boolean isY){
        if(isY){
            if(is2){
                return urlh+"?x-oss-process="+process2+"&OSSAccessKeyId="+OSSAccessKeyId+"&Expires="+Expires+"&Signature="+Signature2;
            }else{
                return url;
            }
        }else{
            return url;
        }
    }

}
